var o = getApp();

Page({
    data: {
        business_id: "",
        code_id: "",
        qRCode: !1,
        qRCodeData: {},
        leftWire: [ "98rpx", "124rpx" ],
        rightWire: [ "98rpx", "124rpx" ],
        shareFigure: [ {
            name: "识别二维码",
            url: "iconfont icon-erweima",
            imageColor: "#fe9a03",
            bgColor: "#fff8ed"
        }, {
            name: "加好友",
            url: "iconfont icon-fontclass-jiahaoyou",
            imageColor: "#2f9cff",
            bgColor: "#eef8fe"
        }, {
            name: "获取链接",
            url: "iconfont icon-ht_operation_copyline",
            imageColor: "#3c6eff",
            bgColor: "#eff3ff"
        } ]
    },
    onLoad: function(o) {
        if (o.scene) {
            var n = decodeURIComponent(o.scene), e = {};
            n.split("&").forEach(function(o, n) {
                e["n".concat(n, "um")] = o.split("=")[1];
            }), console.log(e.n0um, "999"), this.data.business_id = e.n0um, this.data.code_id = e.n1um;
        }
        this.getData();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    getData: function() {
        var n = this, e = this, t = o.getNetAddresss("plugin.drainage-code.frontend.controllers.code"), a = {
            business_id: this.data.business_id,
            code_id: this.data.code_id
        };
        o._postNetWork({
            url: t,
            data: a,
            success: function(o) {
                var t = o.data;
                if (1 == t.result) if (t.data.is_old) {
                    if (!t.data.content.applet) return void wx.showToast({
                        title: "请联系管理员绑定小程序码",
                        icon: "none",
                        duration: 2e3
                    });
                    wx.showModal({
                        cancelColor: "#000000",
                        title: "提示",
                        content: "小程序跳转",
                        success: function(o) {
                            o.confirm ? e.routingHop(t.data.content.applet.page, t.data.content.applet.appid) : console.log("取消");
                        }
                    });
                } else n.setData({
                    qRCodeData: t.data,
                    qRCode: !0
                }), wx.setNavigationBarTitle({
                    title: t.data.code_name
                }); else wx.showToast({
                    icon: "none",
                    title: t.msg,
                    duration: 1e3
                });
            },
            fail: function(o) {
                console.log(o);
            }
        });
    },
    routingHop: function(o, n) {
        wx.navigateToMiniProgram({
            appId: n,
            path: o,
            extraData: {},
            envVersion: "release",
            success: function(o) {
                console.log(o);
            },
            fail: function(o) {
                console.log(o, "报错信息"), wx.showToast({
                    title: "小程序跳转失败",
                    icon: "none",
                    duration: 2e3
                });
            }
        });
    }
});